<?php
/**
 * <https://y.st./>
 * Copyright © 2016 Alex Yst <mailto:copyright@y.st>
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <https://www.gnu.org./licenses/>.
**/

$xhtml = array(
	'title' => 'The \\DatePeriod class',
	'body' => <<<END
<p>
	My project for today was to update my code to use the <a href="https://secure.php.net/manual/en/class.datetime.php"><code>\\DateTime</code> class</a> instead of integer timestamps.
	While fixing up my day_number class, I quickly found the main problem with using the <code>\\DateTime</code> class: it requires instantiation via a date in the form of a string.
	Because several date formats are accepted, dates that are outside the expected range are not handled correctly.
	For example, the year 7 is interpreted as being an alias of the year 2007, though this can be overcome by specifying the year as 0007; the year 10000 causes an error with no workaround.
	I imagine that these corner cases are not the only issue.
	Once a <code>\\DateTime</code> object has been instantiated, the date can be modified using integers, so I extended the class and used this functionality to fix up the constructor method.
	Once I had a functional base class, I hound that my day_number class, which now extends my fixed datetime class, came together much more smoothly than when it was using timestamps.
	Due to the fact that telling the timestamp functions to ignore daylight savings time raises an error, I had been having to rely on hacky workarounds instead.
	Now, everything just fell into place.
	Next, I worked on fixing my calendar function.
	It has now been upgraded to being a class and also extends my datetime class.
	While setting this class up, I found the <a href="https://secure.php.net/manual/en/class.dateperiod.php"><code>\\DatePeriod</code> class</a>.
	As a function, <code>calendar()</code> returned a two-dimensional array to be iterated over by a pair of nested <code>foreach()</code> statements.
	However, the <code>\\DatePeriod</code> class, with zero modifications, took all the effort out of building the second dimension, allowing me to remove some somewhat kludgey code.
	Having the calendar class itself implement the <a href="https://secure.php.net/manual/en/class.iterator.php"><code>\\Iterator</code> interface</a> made the outer iteratable code a bit less concise, but easer to read and understand.
	Finally, I set to work on fixing up my <code>date_nav()</code> function.
	After staring at the code a while, I decided to scrap the function altogether.
	Its main advantage was that it did the leg work of timestamp manipulation for my navigation links.
	However, making use of the <a href="https://secure.php.net/manual/en/class.datetimeimmutable.php"><code>\\DateTimeImmutable</code> class</a> and the <a href="https://secure.php.net/manual/en/class.dateinterval.php"><code>\\DateInterval</code> class</a>, this was a lot less necessary.
	Implementing this code as a function that made use of the date/time classes would have been messier than just using the date/time classes directly and implementing this code as a class would have been messier still.
</p>
<p>
	I was going to implement a similar feature for a descendant of the <code>\\DateTimeImmutable</code> class as I did for a decedent of the <code>\\DateTime</code> class, but I decided that it would be too kludgey for now.
	Due to these objects being immutable, at least in regards to their date and time, I could not use the same simple trick as I had used with the <code>\\DateTime</code> class.
	It could be accomplished using either a non-class function or a static method, but until this functionality is required, I do not want to write such messy code.
</p>
<p>
	I walked over to the local community college today for my appointment with a counselor about the credits that I transfered in.
	It seems that there was bad news.
	I had only one course left to complete to get my associate degree at my last school, but I have about a year&apos;s worth of courses left to take at this school because so many of the credits did not transfer over like I was told that they would.
	Even most of the ones that did transfer over did not meet many of the specific requirements and are just being used to fill all of the elective requirements.
	I do not expect to be in the area beyond the end of next term, so I asked about the school&apos;s online options.
	That lead to even more grim news.
	Offline, I could earn a degree in a tech field, but online, the only options are general education degrees.
	I will speak with my mother after I return from Springfield.
	On the way out, I was offered a chance to get a school $a[ID] card, but I was not told that it required a photograph.
	My hair is still too long, so I would rather avoid getting photo $a[ID] right now.
	Luckily, there were technical difficulties, but even if there were not, it seems that the had left out another important piece of information: students cannot get their student $a[ID] cards until <strong>*after*</strong> enrolling for courses, and I have not done that yet.
	I only just got the information on what courses I even need today.
</p>
<p>
	Tomorrow, I will be headed to Springfield to work on cleaning up and sorting things at our former residence.
	I think that I will be returning on Saturday.
</p>
END
);
